﻿using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MesProjectWinform.Production.Forms.ProductionReport
{
    public partial class QRCodeForm : DevExpress.XtraEditors.XtraForm
    {
        public QRCodeForm(Image qrImage)
        {
            InitializeComponent();
            this.pictureEdit1.Image = qrImage;
            this.pictureEdit1.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom;
        }

        private void QRCodeForm_Load(object sender, EventArgs e)
        {
            // 正确查找GridView
            var gridControl = this.Controls.Find("gridControl1", true).FirstOrDefault() as DevExpress.XtraGrid.GridControl;
            var gridView1 = gridControl?.MainView as DevExpress.XtraGrid.Views.Grid.GridView;
            if (gridView1 != null)
            {
                gridView1.OptionsView.EnableAppearanceEvenRow = true;
                gridView1.Appearance.EvenRow.BackColor = Color.FromArgb(245, 249, 255);
                gridView1.Appearance.HeaderPanel.Font = new Font("微软雅黑", 11, FontStyle.Bold);
                gridView1.Appearance.HeaderPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gridView1.Appearance.Row.Font = new Font("微软雅黑", 10);
                gridView1.OptionsView.ShowGroupPanel = false;
                gridView1.OptionsBehavior.Editable = false;
                gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
                gridView1.OptionsSelection.EnableAppearanceFocusedRow = true;
                gridView1.Appearance.FocusedRow.BackColor = Color.FromArgb(200, 230, 255);
                gridView1.Appearance.FocusedRow.ForeColor = Color.Black;
                gridView1.Appearance.SelectedRow.BackColor = Color.FromArgb(0, 120, 215);
                gridView1.Appearance.SelectedRow.ForeColor = Color.White;
                gridView1.Appearance.Row.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                gridView1.RowHeight = 32;
                gridView1.Appearance.Row.BackColor = Color.White;
                gridView1.Appearance.Row.BorderColor = Color.FromArgb(230, 230, 230);
                gridView1.OptionsView.ShowHorizontalLines = DevExpress.Utils.DefaultBoolean.False;
                gridView1.OptionsView.ShowVerticalLines = DevExpress.Utils.DefaultBoolean.False;
                gridView1.OptionsView.ShowIndicator = false;
            }
            // 按钮美化（如有）
            foreach (var btnName in new[] { "simpleButton1", "simpleButton2", "simpleButton3" })
            {
                var btn = this.Controls.Find(btnName, true).FirstOrDefault() as DevExpress.XtraEditors.SimpleButton;
                if (btn != null)
                {
                    btn.Appearance.Font = new Font("微软雅黑", 10, FontStyle.Bold);
                    btn.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.UltraFlat;
                    btn.Appearance.BackColor = Color.FromArgb(240, 240, 240);
                    btn.Appearance.ForeColor = Color.Black;
                }
            }
        }

        private void QRCodeForm_Load_1(object sender, EventArgs e)
        {

        }
    }
}